/* 在请求token中添加token*/
export function signActionTime(type) {
  let requestType = type.toUpperCase()
  let header = {}
  switch (requestType) {
    case 'GET':
      header = {
        Accept: 'application/json',
        'Content-Type': 'application/json; charset=utf-8',
        Authorization: `${getTokenType()} ${getAccessToken()}`
      }
      break
    case 'POSTFORM':
      header = {
        Accept: 'application/json',
        'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
        Authorization: `${getTokenType()} ${getAccessToken()}`
      }
      break
    case 'POSTJSON':
      header = {
        Accept: 'application/json',
        'Content-Type': 'application/json; charset=utf-8',
        Authorization: `${getTokenType()} ${getAccessToken()}`
      }
      break
    case 'POSTFILE':
      header = {
        Authorization: `${getTokenType()} ${getAccessToken()}`
      }
      break
  }
  return header
}

// 获取accessToken
export function getAccessToken() {
  return localStorage.getItem('accessToken') || ''
}

// 重置accessToken
export function setAccessToken(accessToken) {
  localStorage.setItem('accessToken', accessToken)
}

// 移除accessToken
export function removeAccessToken() {
  localStorage.removeItem('accessToken')
}

// 获取tokenType
export function getTokenType() {
  return localStorage.getItem('tokenType') || ''
}
// 重置tokenType
export function setTokenType(tokenType) {
  localStorage.setItem('tokenType', tokenType)
}
// 移除tokenType
export function removeTokenType() {
  localStorage.removeItem('tokenType')
}

// 获取userinfo
export function getUserInfo() {
  return JSON.parse(localStorage.getItem('userinfo')) || ''
}
// 重置userinfo
export function setUserInfo(userinfo) {
  localStorage.setItem('userinfo', JSON.stringify(userinfo))
}
// 移除userinfo
export function removeUserInfo() {
  localStorage.removeItem('userinfo')
}
// 获取tenantId
export function getTenantId() {
  return localStorage.getItem('tenantId') || ''
}
// 重置tenantId
export function setTenantId(tenantId) {
  localStorage.setItem('tenantId', tenantId)
}
// 移除tenantId
export function removeTenantId() {
  localStorage.removeItem('tenantId')
}

// setRoles
export function setRoles(roles) {
  localStorage.setItem('roles', JSON.stringify(roles))
}

// getRoles
export function getRoles() {
  return JSON.parse(localStorage.getItem('roles')) || []
}

// 移除removeRoles
export function removeRoles() {
  localStorage.removeItem('roles')
}

// setVendorName
export function setVendorName(vendorName) {
  localStorage.setItem('vendorName', vendorName)
}

// 设置用户名
export function setUsername(username) {
  localStorage.setItem('username', JSON.stringify(username))
}

// 设置用户名
export function getUsername() {
  return JSON.parse(localStorage.getItem('username')) || ''
}

// 设置手机号
export function setMobile(mobile) {
  localStorage.setItem('mobile', JSON.stringify(mobile))
}

// 获取手机号
export function getMobile() {
  return JSON.parse(localStorage.getItem('mobile')) || ''
}

// 设置控制台菜单
export function setMenus(menus) {
  localStorage.setItem('MenuList', JSON.stringify(menus))
}

// 获取控制台菜单
export function getMenus() {
  return JSON.parse(localStorage.getItem('MenuList')) || []
}

// 删除控制台菜单
export function removeMenus(menus) {
  localStorage.removeItem('MenuList')
}
// 设置审核状态
export function setIsReviewState(inReviewState) {
  localStorage.setItem('inReviewState', JSON.stringify(inReviewState))
}

// 获取审核状态
export function getIsReviewState() {
  return JSON.parse(localStorage.getItem('inReviewState')) || {}
}
// 获取getGlobalParams 主题色
export function getGlobalParams() {
  return JSON.parse(localStorage.getItem('getGlobalParams')) || ''
}
// 重置getGlobalParams 主题色
export function setGlobalParams(value) {
  localStorage.setItem('getGlobalParams', JSON.stringify(value))
}
// 移除getGlobalParams 主题色
export function removeGlobalParams() {
  localStorage.removeItem('getGlobalParams')
}
// 获取租户的默认参数信息
export function getTenantInfo() {
  return JSON.parse(localStorage.getItem('tenantInfo')) || ''
}
